<?php
class CameraAction extends CcommonAction {
	// 框架首页

	public function index() {	
                cookie("top_menu",null);
		$config = D("Config") -> get_config();
		$this -> assign("home_sort", $config['home_sort']);
                $this->display();
		//$this -> redirect("Camera/index");
	}
        
       public function service(){
                $customer_id = $this -> get_user_id();
		$map['customer_id'] = $customer_id;
                import('ORG.Util.Page');
		$model = D("CameraService");
		$count      = $model->where($map)->count();
                $this-> _config['list_rows'] = 2;//一页展示记录数
                $Page       = new Page($count,$this-> _config['list_rows']);// 实例化分页类 传入总记录数
                $show       = $Page->show();// 分页显示输出
                $list = $model->where($map)->limit($Page->firstRow.','.$Page->listRows)-> field('*') -> select();
                $this->assign('page',$show);// 赋值分页输出
                 foreach($list as $key =>$val){
                   // echo $model_user->get_user_name($val['auditors_id']);
                    $list[$key]['pay_show'] = get_pay_show($val['is_pay']);
                    $list[$key]['leave_data'] = leave_time($val['end_time']);
                    $list[$key]['end_data'] = date('Y-m-d',$val['end_time']);
                    $list[$key]['$status'] =  get_status($val['status']);
                }
                $this -> assign('list', $list);
		$this -> display();
		return;
        }
        
        public function add() {
		$this -> display();
	}
        
        public function myservice(){
                $customer_id = $this -> get_user_id();
		$map['customer_id'] = $customer_id;
		$model = D("CameraMyservice");
                $vo = $model->get_myservice($customer_id);
                $this -> assign('vo', $vo);
		$this -> display();
		return;
        }
        
        public function service_done(){
            $ajax = $_POST['ajax'];
            $service_month = intval(Rv('post','service_month',1));
            $camera_num = intval(Rv('post','camera_num',1));
            $customer_id = $this -> get_user_id();
            $add_time = time();
            $model = D("CameraService");
            $model->__set('service_month',$service_month);
            $model->__set('camera_num',$camera_num);
            $model->__set('customer_id',$customer_id);
            $model->__set('add_time',$add_time);
            $list = $model->add();
            if ($list !== false) {//保存成功
		   $data['info']= '申请已提交';
                   $data['state'] = '1';
                   $data['user_info'] = $customerInfo;
		} else {
			//失败提示
                    $data['info']= '提交失败';
                    $data['state'] = '0';
		}
                 $this -> ajaxReturn($data, "json");
        }
}
?>